@import "variables";

@mixin form-control-focus($color: $input-border-focus) {
  $color-rgba: rgba(red($color), green($color), blue($color), .6);
  &:focus {
    border-color: $color;
    outline: 0;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px $color-rgba;
  }
}
@mixin placeholder($color: $input-color-placeholder) {
  // Firefox
  &::-moz-placeholder {
    color: $color;
    opacity: 1; // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526
  }
  &:-ms-input-placeholder { color: $color; } // Internet Explorer 10+
  &::-webkit-input-placeholder  { color: $color; } // Safari and Chrome
}
@mixin df-form-grid-n($columns: 2){
  $width: 100% / $columns;
  display: flex;
  flex-flow: row wrap;
  > .df-complex-form-group, > .df-form-group{
    flex-grow: 0;
    flex-shrink: 0;
    width: $width;

    @for $i from 0 to $columns{
      &:nth-child(n+#{$i}){
        padding-right: 5px;
      }
    }
  }
}


/*Common*/
.df-form{
  padding: 10px;
  label{
    font-weight: normal;
    margin: 0;
  }
}
.df-complex-form-group{
  > label {
    font-size: 16px;
    color: #aaa;
    display: block;
    line-height: 16px;
    padding: 10px 10px 4px 10px;
    border-bottom: solid 1px #e5e5e5;
  }
}
.df-form-inline{
  .df-input-wrapper, .df-complex-field-wrapper, .df-complex-form-group, .df-form-group, .df-actions{
    display: inline-block;
  }
  .df-input-group{
    display: inline-flex;
  }
  .df-description, .df-help-block{
    display: none;
  }
  .df-complex-form-group, .df-form-group{
    margin-top: 4px;
    margin-right: 10px;
    margin-bottom: 0;
    > label{
      display: inline-block;
    }
    > .df-input-wrapper{
      display: inline-block;
    }
  }
  .df-complex-form-group{
    > label{
      padding: 0 10px;
      display: inline-block;
      border: none;
    }
  }
  .df-complex-field-wrapper{
    padding: 0;
  }
  .df-actions{
    width: auto;
    padding: 0;
    border: none;
    margin-top: inherit;
  }
}

.df-actions{
  width: 100%;
  margin-top: 20px;
  padding: 20px 0 0 0;
  border-top: solid 1px #e2e2e2;
  text-align: right;

  > button{
    margin-left: 10px;
  }
}

@for $i from 0 through 10{
  $width: $i * 10 + 10 + 30;
  $label: '';
  @if $i == 3 {
    $label: '';
  } @else {
    $label: '-' + ($width - 10)
  }
  .df-form-horizontal#{$label}{
    .df-form-group{
      display: flex;

      > label{
        width: #{$width}px;
        height: $form-control-height;
        text-align: right;
        padding: 0 10px 0 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
      }
      > .df-input-wrapper{
        flex: 1;
      }
    }
  }
}



@for $i from 2 through 5{
  .df-form-grid-#{$i}{
    @include df-form-grid-n($i)
  }
}

.df-complex-field-wrapper{
  padding: 10px;
}
.df-description{
  width: 100%;
  font-weight: bold;
  font-style: italic;
  color: #aaa;
}
.df-form-group{
  margin-bottom: 10px;
  > label{
    display: block;
  }
  > .df-input-wrapper{
    display: block;
    > .df-input-wrapper{
      display: block;
    }
  }
}

.df-actions{
  display: block;
}

.df-help-block{
  white-space: normal;
  word-break: break-all;
}

.df-has-error{
  > label, .df-help-block{
    color: $state-danger-text;
  }
  .df-form-control {
    border-color: $state-danger-border;
    @include form-control-focus($state-danger-text);
  }
}

.df-input-group {
  position: relative;
  display: flex;
}
.df-input-group > .df-input-wrapper {
  flex: 1;
}
.df-input-group-addon{
  padding: 0 10px;
  font-size: 14px;
  font-weight: 400;
  line-height: 16px;
  color: #555;
  text-align: center;
  background-color: #eee;
  border: 1px solid #ccc;

  display: inline-flex;
  flex-flow: column;
  justify-content: center;

  &:first-child{
    border-right: 0;
  }
  &:last-child{
    border-left: 0;
  }
}
.df-form-control{
  width: 100%;
  display: block;
  height: $form-control-height;
  line-height: $form-control-height;
  padding: 0 10px;
  vertical-align: middle;
  border: solid 1px #ccc;
  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;

  @include form-control-focus;
  @include placeholder;

  &::-ms-expand {
    border: 0;
    background-color: transparent;
  }

  &[disabled],
  &[readonly],
  fieldset[disabled] & {
    background-color: $input-bg-disabled;
    opacity: 1; // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655
  }

  &[disabled],
  fieldset[disabled] & {
    cursor: not-allowed;
  }
}
.df-input-pending{
  font-size: 12px;
  position: absolute;
  right: 4px;
  top: 50%;
  margin-top: -6px;
  z-index: 10;
  color: #000;
}
.df-input-loading{
  opacity: .8;
}
.df-input-loading-mask{
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  i{
    position: absolute;
    left: 50%;
    top: 50%;
    font-size: 14px;
    margin-left: -7px;
    margin-top: -7px;
  }
}
.df-group-wrapper{
  padding: 10px;
}
.df-button-wrapper{
  position: relative;
  display: block;
}
.df-repeat-item-wrapper{
  position: relative;
}
.df-input-wrapper{
  position: relative;
}
.df-relative{
  position: relative;
}
.df-button-loading{
  > div{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    opacity: .6;
  }
  > i{
    position: absolute;
    top: 50%;
    left: 50%;
    color: #fff;
    font-size: 16px;
    margin-left: -10px;
    margin-top: -8px;
  }
}

/*InputCombo, GridPanel*/
.zoom-in-bottom-enter-active,
.zoom-in-bottom-leave-active {
  opacity: 1;
  transform: scaleY(1);
  transition: all .3s;
  transform-origin: 0 0;
}
.zoom-in-bottom-enter,
.zoom-in-bottom-leave-active {
  opacity: 0;
  transform: scaleY(0);
  transform-origin: 0 0;
}

